/**
 * @param {number[]} capacity
 * @param {number[]} rocks
 * @param {number} additionalRocks
 * @return {number}
 */
 var maximumBags = function(capacity, rocks, additionalRocks) {
  const arr = capacity.map((v,i) => v-rocks[i])
  arr.sort((a,b) => a-b)
  let cnt = 0
  for(let i = 0; i<arr.length; i++) {
    additionalRocks -= arr[i]
    arr[i] = 0
    if(arr[i] > additionalRocks) break
    if(arr[i] === 0) cnt++
  }
  return cnt
};